﻿@{
    ViewBag.Title = "Contact";
}


<div class="row">
    <div class="col-sm-4">
        <label for="sourcetext" class="control-label">原文本</label>
        <textarea id="sourcetext" class="form-control" rows="3" style="min-height: 280px;"></textarea>



    </div>
    <div class="col-sm-2">
        <div style="margin-top:50px">
            <button id="encode" type="button" class="btn btn-primary" style="width:80%;margin:5px;">编码>></button>
            <button id="decode" type="button" class="btn btn-primary" style="width:80%;margin:5px;"><<解码</button>
        </div>
    </div>

    <div class="col-sm-4">
        <label for="targettext" class="control-label">Url安全base64</label>
        <textarea id="targettext" class="form-control" style=" min-height: 280px;"></textarea>
    </div>
</div>

<script>
    $(function () {
        $('#encode').click(function () {
            var source = $('#sourcetext').val();

           var safebase64=  BASE64.urlsafe_encode(source);//url-safe Base64编码
      
            $('#targettext').val(safebase64);
        })

        $('#decode').click(function () {
            var source = $('#targettext').val();

            var safebase64 = BASE64.urlsafe_decode(source);//url-safe Base64编码

            $('#sourcetext').val(safebase64);
        })
    })


</script>